package com.qidian.mes.cal.controller;

import com.qidian.mes.cal.service.CalTeamMemberService;
import com.qidian.mes.pojo.cal.CalTeam;
import com.qidian.mes.pojo.cal.CalTeamMember;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 04冯虹丹
 * @Company 起点编程
 * @Time 2023/10/30 16:20
 * @Description
 */
@RestController
@CrossOrigin
@RequestMapping("/calTeamMember")
public class CalTeamMemberController {
    @Autowired
    private CalTeamMemberService calTeamMemberService;


    /**
     * 分页查询
     * @param page
     * @param limit
     * @param calTeamMember
     * @return
     */
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, CalTeamMember calTeamMember){
        System.out.println("teamId=============*************"+calTeamMember.getTeamId());
        return calTeamMemberService.list(page,limit,calTeamMember);
    }


    /**
     * 根据班组成员Id单个删除
     * @param memberId
     * @return
     */
    @DeleteMapping("/{memberId}")
    public MESResult delete(@PathVariable Long memberId){
        return calTeamMemberService.delete(memberId);
    }

    /**
     * 根据班组成员Id批量删除
     * @param memberId
     * @return
     */
    @DeleteMapping("/deletes")
    public MESResult deletes(Long [] memberId){// 这里接收班组成员id数组的参数名一定要是memberId才能接收到前端传来的数据
        return calTeamMemberService.deletes(memberId);
    }


    /**
     * 添加班组成员
     * @param userId
     * @return
     */
    @GetMapping("/adds")
    public MESResult adds(Long [] userId){
        return calTeamMemberService.save(userId,userId[userId.length-1]);
    }

}
